#pragma once
#include <vector>
#include <string>
#include "ZlgErrorCode.h"
#include "ZlgCanBaudrate.h"

#include "zlgcan/zlgcan.h"


typedef unsigned __int32 uint32_t;
#define TRUE 1
#define FALSE 0

namespace ZlgCan {

#define ZLG_CAN_DEV CAN_DEV_TYPE,CAN_DEV_INDEX,CAN_DEV_ID

	class ZlgCan
	{
	public:
		ZlgErrorCode Open();
		ZlgErrorCode Reset();
		ZlgErrorCode Send(uint32_t canId, std::string data, int delaymilliseconds = 0, int repeatCount = 1, int frameType = 0);
		ZlgErrorCode Receive(uint32_t& canId, std::vector<char>& data, int timeOut = -1);
		ZlgErrorCode ReadErrInfo();
		ZlgErrorCode Close();
	private:
		bool  SetCustomBaudrate();
		bool  SetCanfdBaudrate();
		bool  SetResistanceEnable();

		//CAN 设备类型
		const int CAN_DEV_TYPE = ZCAN_USBCANFD_200U;
		//CAN 设备索引号
		const int CAN_DEV_INDEX = 0;
		//CAN 设备编号
		const int CAN_DEV_ID = 0;

		bool  device_opened_ = FALSE;
		DEVICE_HANDLE device_handle_;
		CHANNEL_HANDLE channel_handle_;

		bool  resistance_enable_ = TRUE;

		int device_index_ = 0;
		int channel_index_ = 0;
		int work_mode_index_ = 0;
		int filter_mode_ = 1;

		// CString acc_code_;
		// CString acc_mask_;
		// CString id_;
		// CString datas_;
		// CString custom_baudrate_;
	};

}